home *** CD-ROM | disk | FTP | other *** search
/ Aminet 22 / Aminet 22 (1997)(GTI - Schatztruhe)[!][Dec 1997].iso / Aminet / dev / c / remote.lha / remote / developer / remoteopen / main.c
C/C++ Source or Header  |  1997-10-09  |  2KB  |  111 lines

  1. /* -----------------------------------------------------------------------------
  2.  
  3.   remoteopen - uses remote.library to start an application
  4.  
  5.   10/1997 Dietmar Eilert (public domain)
  6.  
  7.   dcc main.c -// -mRR -r -proto -3.0 -l /library/dlib/remotesr.lib -o //bin/remoteopen
  8.  
  9.   ------------------------------------------------------------------------------
  10. */
  11.  
  12. /// "includes"
  13.  
  14. #define Prototype extern
  15.  
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <string.h>
  19. #include <ctype.h>
  20. #include <exec/exec.h>
  21. #include <exec/types.h>
  22. #include <dos/dos.h>
  23. #include <clib/alib_protos.h>
  24. #include <clib/dos_protos.h>
  25. #include <clib/exec_protos.h>
  26.  
  27. // remote.library includes
  28.  
  29. #include "/library/include/remote.h"
  30.  
  31. #include "/library/clib/remote_protos.h"
  32.  
  33. ///
  34. /// "prototypes"
  35.  
  36. Prototype int main(int, char **);
  37.  
  38. ///
  39. /// "globals"
  40.  
  41. char Version[] = "$VER: remoteopen 1.0 (" __COMMODORE_DATE__ ")";
  42.  
  43. struct Library *RemoteBase;
  44.  
  45. ///
  46. /// "misc"
  47.  
  48. /* ----------------------------------- main ------------------------------------
  49.  
  50.  DOS entry point
  51.  
  52. */
  53.  
  54. int
  55. main(argc, argv)
  56.  
  57. int    argc;
  58. char **argv;
  59. {
  60.     int error = 0;
  61.  
  62.     puts("remoteopen 10/1997 Dietmar Eilert. Public Domain.");
  63.  
  64.     if (RemoteBase = OpenLibrary("remote.library", 37)) {
  65.  
  66.         // manually initialize remote.library (we want to see the error code)
  67.  
  68.         if (error = RemoteInit()) {
  69.  
  70.             puts(RemoteError(error));
  71.         }
  72.         else {
  73.  
  74.             ULONG argArray[] = { 0, 0, 0 };
  75.  
  76.             struct RDArgs *rdArgs;
  77.  
  78.             // parse arguments
  79.  
  80.             if (rdArgs = ReadArgs("CLASS/A,FILE/K,APP/K", argArray, NULL)) {
  81.  
  82.                 // open file in application
  83.  
  84.                 if (error = RemoteOpen((UBYTE *)argArray[0], (UBYTE *)argArray[2], (UBYTE *)argArray[1], REMOTE_OPEN_ASYNC))
  85.  
  86.                     puts(RemoteError(error));
  87.  
  88.                 FreeArgs(rdArgs);
  89.             }
  90.             else {
  91.  
  92.                 error = 20;
  93.  
  94.                 puts("Syntax error.");
  95.             }
  96.         }
  97.  
  98.         CloseLibrary(RemoteBase);
  99.     }
  100.     else {
  101.  
  102.         error = 20;
  103.  
  104.         puts("remote.library missing");
  105.     }
  106.  
  107.     return(error);
  108. }   
  109.  
  110. ///
  111.